package com.example.clxy.controller;

import com.example.clxy.entity.Program;
import com.example.clxy.interceptor.AppToken;
import com.example.clxy.result.PageResult;
import com.example.clxy.result.WebRestResult;
import com.example.clxy.result.business.PageResult.ExperimentPageResult;
import com.example.clxy.result.business.PageResult.PlatformPageResult;
import com.example.clxy.result.business.PageResult.ProgramPageResult;
import com.example.clxy.result.business.PageResult.SycoursePageResult;
import com.example.clxy.service.ProgramService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author weichong
 * date 2020-08-04
 * @Description:
 */
@AppToken
@RestController
@RequestMapping("ProgramController")
public class ProgramController {
    @Autowired
    private ProgramService programService;

    /**
     * 新增培养方案接口
     * @param program 培养方案类
     */
    @RequestMapping("addProgram")
    public WebRestResult addProgram(@RequestBody Program program){
        WebRestResult res = programService.addProgram(program);
        return res;
    }

    @RequestMapping("updateProgram")
    public WebRestResult updateProgram(@RequestBody Program program){
        WebRestResult res = programService.updateProgram(program);
        return res;
    }


    /**
     * 查询所有培养方案接口
     */
    @RequestMapping("getProgramList")
    public PageResult<ProgramPageResult> getProgramList(String programid, String programname, String year, String procode, String schoolname, String status, int page, int pagesize){
        PageResult<ProgramPageResult> res = programService.getProgramList(programid,programname,year,procode,schoolname,status,page,pagesize);
        return res;
    }

    /**
     * 新增某培养方案下实验课程接口
     */
    @RequestMapping("addProgramSycourse")
    public WebRestResult addProgramSycourse(String programid,String sycourseid){
        WebRestResult res = programService.addProgramSycourse(programid,sycourseid);
        return res;
    }

    /**
     * 新增xx培养方案下xx实验课程与子实验关系接口
     */
    @RequestMapping("addProgramSycourseExperiment")
    public WebRestResult addProgramSycourseExperiment(String programid,String sycourseid,String experimentid){
        WebRestResult res = programService.addProgramSycourseExperiment(programid,sycourseid,experimentid);
        return res;
    }

    /**
     * 新增某培养方案下平台接口
     */
    @RequestMapping("addProgramPlatform")
    public WebRestResult addProgramPlatform(String programid,String platformid){
        WebRestResult res = programService.addProgramPlatform(programid,platformid);
        return res;
    }

    /**
     * 新增xx培养方案下xx平台与子实验关系接口
     */
    @RequestMapping("addProgramPlatformExperiment")
    public WebRestResult addProgramPlatformExperiment(String programid,String platformid,String experimentid){
        WebRestResult res = programService.addProgramPlatformExperiment(programid,platformid,experimentid);
        return res;
    }

    /**
     * 删除xx培养方案下的实验课程关系接口,以及该课程下的所有子实验关系
     */
    @RequestMapping("deleteProgramSycourse")
    public WebRestResult deleteProgramSycourse(String programid,String sycourseid){
        WebRestResult res = programService.deleteProgramSycourse(programid,sycourseid);
        return res;
    }

    /**
     * 删除xx培养方案下xx实验课程与子实验的关系接口
     */
    @RequestMapping("deleteProgramSycourseExperiment")
    public WebRestResult deleteProgramSycourseExperiment(String programid,String sycourseid,String experimentid){
        WebRestResult res = programService.deleteProgramSycourseExperiment(programid,sycourseid,experimentid);
        return res;
    }

    /**
     * 删除xx培养方案与平台的关系,以及该平台与所有子实验的关系
     */
    @RequestMapping("deleteProgramPlatform")
    public WebRestResult deleteProgramPlatform(String programid,String platformid){
        WebRestResult res = programService.deleteProgramPlatform(programid,platformid);
        return res;
    }

    /**
     * 删除xx培养方案下xx平台与子实验的关系接口
     */
    @RequestMapping("deleteProgramPlatformExperiment")
    public WebRestResult deleteProgramPlatformExperiment(String programid,String platformid,String experimentid){
        WebRestResult res = programService.deleteProgramPlatformExperiment(programid,platformid,experimentid);
        return res;
    }

    /**
     * 查询xx培养方案所有实验课程接口
     */
    @RequestMapping("getAllSycourseOfProgram")
    public PageResult<SycoursePageResult> getAllSycourseOfProgram(String programid, String sycoursename, int page, int pagesize){
        PageResult<SycoursePageResult> res = programService.getAllSycourseOfProgram(programid,sycoursename,page,pagesize);
        return res;
    }

    /**
     * 查询xx培养方案所有平台接口
     */
    @RequestMapping("getAllPlatformOfProgram")
    public PageResult<PlatformPageResult> getAllPlatformOfProgram(String programid, String platformname, int page, int pagesize){
        PageResult<PlatformPageResult> res = programService.getAllPlatformOfProgram(programid,platformname,page,pagesize);
        return res;
    }

    /**
     * 查询xx培养方案下xx实验课程所有子实验信息接口
     */
    @RequestMapping("getAllExperimentOfProgramSycourse")
    public PageResult<ExperimentPageResult> getAllExperimentOfProgramSycourse(String programid, String sycourseid, String experimentname, int page, int pagesize){
        PageResult<ExperimentPageResult> res = programService.getAllExperimentOfProgramSycourse(programid,sycourseid,experimentname,page,pagesize);
        return res;
    }

    /**
     * 查询xx培养方案下xx平台子实验信息接口
     */
    @RequestMapping("getAllExperimentOfProgramPlatform")
    public PageResult<ExperimentPageResult> getAllExperimentOfProgramPlatform(String programid, String platformid, String experimentname, int page, int pagesize){
        PageResult<ExperimentPageResult> res = programService.getAllExperimentOfProgramPlatform(programid,platformid,experimentname,page,pagesize);
        return res;
    }

    /**
     *  查询xx培养方案下所有实验课程及子实验信息接口
     */
    @RequestMapping("getProgramSycourseExperiment")
    public PageResult<SycoursePageResult> getProgramSycourseExperiment(String programid, int page, int pagesize){
        PageResult<SycoursePageResult> res = programService.getProgramSycourseExperiment(programid,page,pagesize);
        return res;
    }

    /**
     * 查询xx培养方案下所有平台及子实验信息接口
     */
    @RequestMapping("getProgramPlatformExperiment")
    public PageResult<PlatformPageResult> getProgramPlatformExperiment(String programid, int page, int pagesize){
        PageResult<PlatformPageResult> res = programService.getProgramPlatformExperiment(programid,page,pagesize);
        return res;
    }

    @RequestMapping("copyProgram")
    public WebRestResult copyProgram(String oldprogramid, String newprogramid){
        return programService.copyProgram(oldprogramid,newprogramid);
    }

}
